var expiredata = 1;
var moment = require('moment');
var jwt = require('jwt-simple');
var jwtTokenSecret='gy_liliang_waibao';
exports.create_token= function(Account_id){

	var expires =moment().add(expiredata, 'days').valueOf();
	 
	var token = jwt.encode({
        iss: Account_id,
        exp: expires,
      }, jwtTokenSecret);

     return token;
};

exports.check_token= function(token){
	var decoded = jwt.decode(token,jwtTokenSecret);
	if (decoded.exp <= Date.now()) {
		console.log('授权错误');
	    return -1;
	  } else {
		  return decoded.iss;
	 }
};
